package com.hong;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.hong.dubbo.api.HelloDubboService;

/**
 * Created by John on 2019/3/2.
 */
public class Application {
    public static void main(String[] args) {
        /**
         * 直接通过Java代码的方式RPC消费服务
         */
        ReferenceConfig<HelloDubboService> reference = new ReferenceConfig<>();
        reference.setApplication(new ApplicationConfig("dubbo-consumer2"));
        reference.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
        reference.setInterface(HelloDubboService.class);
        HelloDubboService service = reference.get();
        String message = service.sayHello("你大爷的");
        System.out.println(message);
    }

}
